package com.wsoft.bpm.node;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.lang.reflect.Field;

/**
 * @Author zhonglj
 * @Date 2024-09-13 14:49
 */
@Getter
@Setter
@Accessors(chain = true)
public class TimerEventDefinition extends ActivityXml {
    private TimeDate timeDate;
    private TimeCycle timeCycle;
    private TimeDuration timeDuration;

    public TimerEventDefinition() {
        setTagName("timerEventDefinition");
    }

    @Override
    public Boolean skip(Field field) {
        // 优先级顺序：timeDate timeCycle timeDuration
        if ("timeCycle" .equals(field.getName()) && timeDate != null) {
            return true;
        }

        boolean b = timeDate != null || timeCycle != null;
        if ("timeDuration" .equals(field.getName()) && b) {
            return true;
        }

        return false;
    }
}
